//
//  InterfaceController.swift
//  YFWatchDemo WatchKit Extension
//
//  Created by FYWCQ on 2019/6/28.
//  Copyright © 2019 YFWCQ. All rights reserved.
//

import WatchKit
import Foundation
import Moya_ObjectMapper
import Alamofire
import Result
import Moya
import HandyJSON

class InterfaceController: WKInterfaceController {

    override func awake(withContext context: Any?) {
        super.awake(withContext: context)
        
        print("*******000000000*********")
//        if DDEVELOPMENT == 0 {
//            
//        }
        
        NetWorkRequest(.userToken, completion: { (repoObject) -> (Void) in
            if let repo:ResponceToken = repoObject as? ResponceToken {
                if let token = repo.data?.token {
                    print(token + "dsfafasoooooooofasdf")
                }
            }
            
        }, reponceType: ResponceToken.self, failed: { (erroString) -> (Void) in
            print(erroString)
        }) { (error) -> (Void) in
            print(error)
        }
       
//        Provider.request(.userToken, completion: { [weak self] result in
//
//            switch result {
//            case let .success(response): do {
//
//
//                let resJson: [String : Any]? = try response.mapJSON() as? [String : Any]
//                if let object =  ResponceToken.deserialize(from: resJson) {
//                    print("dfasfasdfa")
//                }
//
//
//
////                let repos: Responce? = try response.mapObject(Responce.self)
////
////                print("fdfasdfsadfdsa")
////                print(repos?.level)
////
//                }
//                catch {
//                print("error++")
//                }
//                case let .failure(error): do {
//                print(error)
//                }
//            }
//
//        })
//
//
        
        
//        let loginParam = QCLoginParam(JSONString: "")
//
//        if let loginParamYY = loginParam {
//
//            provier.request(QCWatchLoginApi(parameters: loginParamYY)) {  [weak self] result  in
//
//                var success = true
//                var message = "Unable to fetch from GitHub"
//                var repositores: [Repository]? = nil
//                switch result {
//                case let .success(response):
//                    do {
//                        let repos: [Repository]? = try response.mapArray(Repository.self)
//                        if let repos = repos {
//                            // Presumably, you'd parse the JSON into a model object. This is just a demo, so we'll keep it as-is.
//                            repositores = repos
//                        } else {
//                            success = false
//                        }
//                    } catch {
//                        success = false
//                    }
//                case let .failure(error):
//                    guard let description = error.errorDescription else {
//                        break
//                    }
//                    message = description
//                    success = false
//                }
//
//            }
//
//
//
//
//        }
    }
    
    override func willActivate() {
        // This method is called when watch view controller is about to be visible to user
        super.willActivate()
    }
    
    override func didDeactivate() {
        // This method is called when watch view controller is no longer visible
        super.didDeactivate()
    }

}
